# 错误不是要所有的左右子树都相等，一定要明白题的要求
class Solution:
    def isSymmetric(self, root: TreeNode) -> bool:
        if not root:
            return True
        if self.isSymmetric(root.left) and self.isSymmetric(root.right) and root.left == root.right:
            return True
        return False

# 正确的做法
class Solution:
    def isSymmetric(self, root: TreeNode) -> bool:
        def check(a, b):
            if a == None and b == None:
                return True
            if a == None or b == None:
                return False
            # 一定要用val这里易错
            return a.val == b.val and check(a.left,b.right) and check(a.right,b.left)
        return check(root, root)

